#pragma once

#include <stack>
#include <queue>
#include <memory>

class SCRGame;
class SCRGameState;

typedef std::tr1::shared_ptr<SCRGameState> SCRGameStatePtr;

class SCRGameStateManager
{
public:

	~SCRGameStateManager();
	SCRGameStatePtr IsRunning(const int& Delta);
	void ClearQueue();
	void Pop();
	template <class T> void Push();
	template <class T> void Push(const char* DataA, const int& Size);
	template <class T> void SwitchTo();
	template <class T> void SwitchTo(const char* DataA, const int& Size);

	friend class SCRGame;

private:

	SCRGameStateManager();
	void Push(SCRGameState* pState);

	std::stack<SCRGameStatePtr> m_StateStack;
	std::queue<SCRGameStatePtr> m_StateQueue;
};

template <class T> void SCRGameStateManager::Push()
{
	Push(new T());
}

template <class T> void SCRGameStateManager::Push(const char* DataA, const int& Size)
{
	Push(new T(DataA, size));
}

template <class T> void SCRGameStateManager::SwitchTo()
{
	Pop();
	Push<T>();
}

template <class T> void SCRGameStateManager::SwitchTo(const char* DataA, const int& Size)
{
	Pop();
	Push<T>(DataA, Size);
}
